// ==UserScript==
// @name           Yahoo Fantasy Baseball Distinguish Positions
// @namespace      http://glenncarr.com/greasemonkey
// @description    Distinguish positions on league roster page
// @include        *baseball.fantasysports.yahoo.com/*/startingrosters
// @author         Glenn Carr (glenn at glenncarr dot com)
// $LastChangedRevision: 558 $
// $LastChangedDate: 2010-04-07 23:08:09 +0000 (Wed, 07 Apr 2010) $
// ==/UserScript==

(function() {

try {

var colors = {};
colors[ 'P' ] = '#D0A9F5';
colors[ 'RP' ] = '#F5A9F2';
colors[ 'SP' ] = '#D0A9F5';
colors[ 'SS' ] = '#FFFF00';
colors[ '2B' ] = '#FAFD98';
colors[ 'OF' ] = '#00FFFF';

var players = document.evaluate( '//td[contains(@class,"player")]/div[@class="detail"]/..', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if ( players.snapshotLength == 0 )
    return;
    
GM_addStyle( 'a.name, a.name:link, a.name:visited, a.name:active { color:#0069AA; }' );

for ( var iPlayer = 0; iPlayer < players.snapshotLength; iPlayer++ )
{
    var playerCell = players.snapshotItem( iPlayer );
   
    var posEl = playerCell.getElementsByTagName( 'SPAN' )[ 0 ];
    if ( /\bP\b/.test( posEl.innerHTML ) ) 	   					playerCell.style.background = '#D0A9F5';
    else if ( /\bRP\b/.test( posEl.innerHTML ) )  				playerCell.style.background = '#F5A9F2';
    else if ( /\bSP\b/.test( posEl.innerHTML ) )  				playerCell.style.background = '#D0A9F5';
    else if ( /\bRP\b/.test( posEl.innerHTML ) )  				playerCell.style.background = '#FFFF00';
    else if ( /\b1B\b/.test( posEl.innerHTML ) )  				playerCell.style.background = '#FE9A2E';
    else if ( /\b2B\b/.test( posEl.innerHTML ) )  				playerCell.style.background = '#FAFD98';
    else if ( /\bSS\b/.test( posEl.innerHTML ) )  				playerCell.style.background = '#FFFF00';
    else if ( /\bC\b/.test( posEl.innerHTML ) )  				playerCell.style.background = '#00FF00';
    else if ( /\b3B\b/.test( posEl.innerHTML ) )  				playerCell.style.background = '#FFCC00';
    else if ( /\b(OF|RF|LF|CF)\b/.test( posEl.innerHTML ) )  	playerCell.style.background = '#00FFFF';
    else if ( /\bUtil\b/i.test( posEl.innerHTML ) )  	playerCell.style.background = '#cccccc';
}

} catch ( e ) { alert( e ); }
})();